#ifndef RING_BUFFER_H
#define RING_BUFFER_H

#include <stdint.h>
#include <stdbool.h>

#define RING_BUFFER_SIZE 128

typedef struct {
    uint8_t buffer[RING_BUFFER_SIZE];   
    volatile uint16_t head;             
    volatile uint16_t tail;              
    volatile uint16_t count;             
} RingBuffer_t;

void ring_buffer_init(RingBuffer_t *rb);
bool ring_buffer_push(RingBuffer_t *rb, uint8_t data);
bool ring_buffer_pop(RingBuffer_t *rb, uint8_t *data);
bool ring_buffer_push_array(RingBuffer_t *rb, const uint8_t *data, uint16_t len);
bool ring_buffer_pop_array(RingBuffer_t *rb, uint8_t *data, uint16_t len);
uint16_t ring_buffer_available(RingBuffer_t *rb);
uint16_t ring_buffer_free_space(RingBuffer_t *rb);
bool ring_buffer_is_empty(RingBuffer_t *rb);
bool ring_buffer_is_full(RingBuffer_t *rb);
void ring_buffer_clear(RingBuffer_t *rb);
bool ring_buffer_peek(RingBuffer_t *rb, uint8_t *data, uint16_t offset);

#endif 